home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 751 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: gets() question
  5. Date: Tue, 09 Jan 96 01:37:04 GMT
  6. Organization: none
  7. Message-ID: <821151424snz@genesis.demon.co.uk>
  8. References: <4cosgf$rir@newsbf02.news.aol.com> <4cqkt8$1quo@news.gate.net> <TANMOY.96Jan8084126@qcd.lanl.gov>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <TANMOY.96Jan8084126@qcd.lanl.gov>
  15.            tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes:
  16.  
  17. >--text follows this line--
  18. >In article <821109116snz@genesis.demon.co.uk> Lawrence Kirby
  19. ><fred@genesis.demon.co.uk> writes: 
  20. ><snip>
  21. >   It is certainly better to use fgets rather than gets but you could have
  22. >   written:
  23. >
  24. >            fgets(s[0],sizeof s[0],stdin);
  25. >
  26. >   s[0] is equivalent to &s[0][0] in this context and is arguably more
  27. >   readable. The length argument of fgets specifies the size of the array
  28. >
  29. >Just to point out the obvious, the first s[0] is equivalent to
  30. >&s[0][0]. The s[0] in sizeof s[0] is not!
  31.  
  32. Right! You might consider that neither & not sizeof take the value of
  33. their operand (i.e. treat it as an rvalue). & takes an lvalue and returns
  34. a pointer to the dsignated object, and sizeof takes an explicit type or the
  35. type from an expression (but not the value, indeed the expression is not
  36. evaluated at all).
  37.  
  38. -- 
  39. -----------------------------------------
  40. Lawrence Kirby | fred@genesis.demon.co.uk
  41. Wilts, England | 70734.126@compuserve.com
  42. -----------------------------------------
  43.